--
-- Author: shunguo.chen
-- Date: 2017-01-09 16:20:20
--

local GameDB = import(".GameDB")

--[[--
-- 获得所有职业数据
]]
function GameDB:queryAllClass()
	local res = self:getCachedTable("class")
	return res
end

function GameDB:queryClass(classID)
	return self:getCachedValue("class",classID) or {}
end

function GameDB:queryClassByShowteam(showTeam)
    local key = tostring(showTeam)
    local configs = self:getCachedValues("class",function(v)
        return v.showteam==key
    end)
    return configs
end

--[[--
-- 查询指定职业的名字
]]
function GameDB:queryClassName(tid)
    local classConfig = self:getCachedValue("class",tid) or {}
    local className = classConfig.string or ""
	return className
end

function GameDB:getClassName(classId)
	local conf = GD:queryClass(classId)
	--print("GameDB:getClassName", L(conf.string))
	return L(conf.string, classId)
end

function GameDB:getClassIcon(classId, index)
	if not classId then return end
	--print("GameDB:getClassIcon classId index", classId, index)
	local conf = self:queryClass(classId)
	if conf then
		local icon
		if index == 1 then
			icon = conf.icon
		else
			icon = conf["icon"..index]
		end
		return Res.classIconPath .. ( ( nil ~= icon ) and icon or "101" ) .. ".png"
	end
end

return GameDB